package com.oscar.ehome.base;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;

import com.google.gson.Gson;

public class BaseListBean<T> {
	/** 成功状态 0:失败，1:成功 */
	private Integer success;
	/** 消息信息 */
	private String message;
	/** 消息对象 */
	private List<T> object;

	public Integer getSuccess() {
		return success;
	}

	public void setSuccess(Integer success) {
		this.success = success;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public List<T> getObject() {
		return object;
	}

	public void setObject(List<T> object) {
		this.object = object;
	}

	public static BaseListBean fromJson(String json, Class clazz) {
		return new Gson().fromJson(json, type(BaseListBean.class, clazz));
	}

	private static ParameterizedType type(final Class raw, final Type... clazz) {
		return new ParameterizedType() {
			public Type getRawType() {
				return raw;
			}

			public Type[] getActualTypeArguments() {
				return clazz;
			}

			public Type getOwnerType() {
				return null;
			}
		};
	}
}
